package com.bestv.search.engine.command;

import com.bestv.search.common.cache.SystemCache;
import com.bestv.search.common.dataSource.DataSourceKey;
import com.bestv.search.common.dataSource.DataSourceKeyUtil;
import com.bestv.search.common.model.KeySubject;
import com.bestv.search.common.service.KeySubjectManager;

import java.util.Date;
import java.util.List;

public class KeySubjectCommand {

    private KeySubjectManager keySubjectManager;
    private SystemCache systemCache;

    public int getOnLineKeySubjectsCount() {
        DataSourceKey key = DataSourceKeyUtil.convert(systemCache.getLocalDataSourceKey());
        return keySubjectManager.getOnLineKeySubjectsCount(key);

    }

    public List<KeySubject> getOnLineKeySubjects(int start, int limit) {
        DataSourceKey key = DataSourceKeyUtil.convert(systemCache.getLocalDataSourceKey());
        return keySubjectManager.getOnLineKeySubjects(key, start, limit);
    }

    public List<KeySubject> getKeySubjectsByUpdateTimeForIndex(Date updateTimeForIndex) {
        DataSourceKey key = DataSourceKeyUtil.convert(systemCache.getLocalDataSourceKey());
        return keySubjectManager.getKeySubjectsByUpdateTimeForIndex(key, updateTimeForIndex);
    }

    public KeySubjectManager getKeySubjectManager() {
        return keySubjectManager;
    }

    public void setKeySubjectManager(KeySubjectManager keySubjectManager) {
        this.keySubjectManager = keySubjectManager;
    }

    public SystemCache getSystemCache() {
        return systemCache;
    }

    public void setSystemCache(SystemCache systemCache) {
        this.systemCache = systemCache;
    }
}